package com.secret.service;

import com.secret.controller.HelloController;
import com.secret.dao.UserDao;
import com.secret.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * impl
 *
 * @author: x.xu
 * 2023-02-24 16:16
 **/
@Component
public class UserServiceImpl implements UserService {
    private final static Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
    @Autowired
    UserDao userDao;

    public List<User> getUser(String name){
        String queryString = "select s.* from t_user s where s.name like'%"+name+"%'";
        logger.info("  queryString : {} ",queryString);
        List<User> users = userDao.getBySql(queryString,User.class);
        userDao.close();
        return users;
    }

    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }
}
